function plot_dof
% this function is to plot the different dof sort scheme
v1 = [1,1.5];
v2 = [0,0];
v3 = [2,0];
T = [1,2,3];
V = [v1;v2;v3];

%-----------------draw my scheme first-------------
% for degree 4
d = 4; figure('Position',[100,100,300,300]);
m = (d+1)*(d+2)/2;
str = num2str((1:m)');
[I,J,K] = indices(d);
plot_t(V,T);hold on;
plot((I*v1(1)+J*v2(1)+K*v3(1))/d,(I*v1(2)+J*v2(2)+K*v3(2))/d,'r.');
text((I*v1(1)+J*v2(1)+K*v3(1))/d-0.12,(I*v1(2)+J*v2(2)+K*v3(2))/d-0.02,str,'FontSize',20);
text(v1(1)-0.2,v1(2)+0.05,'V1','Color','red','FontSize',15)
text(v2(1)-0.15,v2(2)-0.15,'V2','Color','red','FontSize',15)
text(v3(1),v3(2)-0.15,'V3','Color','red','FontSize',15)
axis tight; axis off;hold off;

% for degree 5
d = 5; figure('Position',[400,100,300,300]);
m = (d+1)*(d+2)/2;
str = num2str((1:m)');
[I,J,K] = indices(d);
plot_t(V,T);hold on;
plot((I*v1(1)+J*v2(1)+K*v3(1))/d,(I*v1(2)+J*v2(2)+K*v3(2))/d,'r.');
text((I*v1(1)+J*v2(1)+K*v3(1))/d-0.12,(I*v1(2)+J*v2(2)+K*v3(2))/d-0.02,str,'FontSize',20);
text(v1(1)-0.2,v1(2)+0.05,'V1','Color','red','FontSize',15)
text(v2(1)-0.15,v2(2)-0.15,'V2','Color','red','FontSize',15)
text(v3(1),v3(2)-0.15,'V3','Color','red','FontSize',15)
axis tight; axis off;hold off;

%-----------------scheme for lai----------------------
% for degree 4
d = 4; figure('Position',[100,400,300,300]); 
m = (d+1)*(d+2)/2;
str = num2str((1:m)');
[I,J,K] = indices_lai(d);
plot_t(V,T);hold on;
plot((I*v1(1)+J*v2(1)+K*v3(1))/d,(I*v1(2)+J*v2(2)+K*v3(2))/d,'r.');
text((I*v1(1)+J*v2(1)+K*v3(1))/d-0.12,(I*v1(2)+J*v2(2)+K*v3(2))/d-0.02,str,'FontSize',20);
text(v1(1)-0.2,v1(2)+0.05,'V1','Color','red','FontSize',15)
text(v2(1)-0.15,v2(2)-0.15,'V2','Color','red','FontSize',15)
text(v3(1),v3(2)-0.15,'V3','Color','red','FontSize',15)
axis tight; axis off;hold off;

% for degree 5
d = 5;figure('Position',[400,400,300,300]);
m = (d+1)*(d+2)/2;
str = num2str((1:m)');
[I,J,K] = indices_lai(d);
plot_t(V,T);hold on;
plot((I*v1(1)+J*v2(1)+K*v3(1))/d,(I*v1(2)+J*v2(2)+K*v3(2))/d,'r.');
text((I*v1(1)+J*v2(1)+K*v3(1))/d-0.12,(I*v1(2)+J*v2(2)+K*v3(2))/d-0.02,str,'FontSize',20);
text(v1(1)-0.2,v1(2)+0.05,'V1','Color','red','FontSize',15)
text(v2(1)-0.15,v2(2)-0.15,'V2','Color','red','FontSize',15)
text(v3(1),v3(2)-0.15,'V3','Color','red','FontSize',15)
axis tight; axis off;hold off;


function [I,J,K] = indices_lai(d)
%        [I,J,K] = indices_lai(d)
% This function computes the index vectors I,J,K associated with our linear ordering
% for the Bnet coefficients of a polynomial of degree d over an arbitrary triangle.
% This matlab program is copyrighted @2001 by Ming-Jun Lai and Paul Wenston
% through University of Georgia Research Foundation, Inc..
m = (d+1)*(d+2)/2;
I = zeros(m,1);
J = I;
K = I;
Mark = 1;
for j = d:(-1):0
   I(Mark:(Mark+j)) =[j:(-1):0]';
   J(Mark:(Mark+j)) =[0:j]';
   K(Mark:(Mark+j)) =(d-j)*ones(j+1,1);
   Mark = Mark+j+1;
end;